package genedit.gui.propertyDialogs;

import genedit.gui.GMainFrame;
import genedit.gui.exceptions.RequiredFieldException;
import genedit.model.graph.GraphElement;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;

/**
 * Klasa AbstractDialog je apstraktni predak svih dijaloga za prikaz podataka u aplikaciji 
 * (dijalozi sa tabelom). Sadrži toolbar, tabelu, panel sa detaljima i status-bar.
 * Naslednici definišu naslov prozora, kolone tabele i konkretan panel sa detaljima.
 * Metode dodavanje/izmena/brisanje/pretraga se pozivaju iz odgovarajućih dugmića na toolbaru.
 * Naslednici treba da ih redefinišu.
 */
@SuppressWarnings("serial")
public abstract class AbstractDialog extends JDialog {
	
	// stanje dijaloga: pregled, dodavanje sloga, izmena sloga, pretraga
	public enum StanjeDijaloga {BROWSE, ADD, UPDATE};
	
	

	protected JFrame parent;
	protected GMainFrame mf = GMainFrame.getInstance();
	protected DialogToolbar toolbar;
	protected JTabbedPane jtabbed;
	protected GraphElement element;
	protected JLabel lblNameDialog;
	protected JTextField txtNameDialog;
	protected JSplitPane splitPane;
	protected JButton btnOkDialog;
	protected JPanel panClassAttributes;
	
	public AbstractDialog(JFrame parent) {
		
		super(parent, true);
		this.parent = parent;
		setSize(mf.getWidth()/3, 2*mf.getHeight()/5);
		setLocationRelativeTo(parent);
	}
	
	

protected void initGUI() {
		
		toolbar = new DialogToolbar(this);
		
		Dimension lblDimension = new Dimension(70,20);
		panClassAttributes = new JPanel(new FlowLayout(FlowLayout.LEFT));
		lblNameDialog = new JLabel(GMainFrame.getInstance().getResourceBundle().getString("lblName"));
		lblNameDialog.setPreferredSize(lblDimension);
		txtNameDialog = new JTextField(10);
		txtNameDialog.setText(element.getName());
		panClassAttributes.add(lblNameDialog);
		panClassAttributes.add(txtNameDialog);
	
		Dimension minimumSize = new Dimension(this.getWidth(), 30);
		panClassAttributes.setMinimumSize(minimumSize);
		jtabbed = new JTabbedPane();
		splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
				 toolbar,panClassAttributes);
		splitPane.setMinimumSize(minimumSize);
		splitPane.setResizeWeight(0.0);
		add(splitPane,  BorderLayout.NORTH);
		
		
		

	}

	public abstract void dodavanje();
	public abstract void izmena();
	public abstract void brisanje();
	

	

}